﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace Pavilion
{
    public abstract class LockMonitorBase
    {
        public event Action<LockMonitorBase> LockOpened;

        public abstract ILock Lock { get; }

        private bool _isOpen;

        public abstract void Dispose();
        public abstract void Load(GameItem gameItem);
        public abstract void UpdateLock();

        public bool IsOpen
        {
            get { UpdateLock(); return _isOpen; }
            protected set
            {
                if (_isOpen == value)
                    return;

                _isOpen = value;

                if (_isOpen)
                    OnLockOpened();
            }
        }

        private void OnLockOpened()
        {
            if (LockOpened != null)
                LockOpened(this);
        }
    }
}
